package DataBase;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Vector;

public class GetItemById {
	private String id;

	public GetItemById(String id) {
		this.id = id;
	}

	public Vector<String> getItem() {
		Vector<String> item = new Vector<String>();
		SQLConnection sc = new SQLConnection();

		try {

			PreparedStatement ps = sc.getConnection().prepareStatement("SELECT * FROM item WHERE Iid = ?;");
			ps.setString(1, this.id.trim());
			ResultSet rs = ps.executeQuery();

			ResultSetMetaData rsmd = rs.getMetaData();

			while (rs.next()) {

				for (int col = 1; col <= rsmd.getColumnCount(); col++) {
					item.add(rs.getString(col));
				}// for
			}// while
		     ps.close();
			 rs.close();
			 sc.getConnection().close();

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return item;
	}
}
